

/*当ie版本低于IE9时，复选框选中效果*/
$(function() {
  var browser = navigator.appName;
  var b_version = navigator.appVersion;
  var version = b_version.split(";");
  var trim_Version ="";
  if(version.length>1){
      trim_Version = version[1].replace(/[ ]/g, ""); 
  }
  if (browser == "Microsoft Internet Explorer" && trim_Version == "MSIE8.0") {
    $('.checkbox label').hide();
    $('.checkbox input').show();
  }
    
});


/*新增角色*/
function addRole(){
    $("body").on("click", ".add-role", function(){
        $(".win-add-role input[type=text]").val("").focus();
    })
}

/*编辑角色名称*/
function editRoleName(){
    $("body").on("click", ".edit-role-name", function(){
        var roleName = $(this).parents("tr").children("td").eq(0).text();
        $(".win-edit-role input[type=text]").val(roleName).focus();
    })
}

/*角色成员添加和删除*/
function addAndDelMember(){

    //选中成员
    $(".win-members").on("mousedown","li",function(){
        if(!$(this).hasClass("disabled")){
            $(this).toggleClass("selected");
            $(this).parents("ul").siblings("ul").children("li").removeClass("selected");
        }
    });

    //添加选中成员
    $(".add-members").click(function(){
        var selDom = $(".all-members li.selected");
        $(".selected-members").append(selDom);

    });

    //删除选中成员
    $(".del-members").click(function(){
        var selDom = $(".selected-members li.selected");
        $(".all-members").append(selDom);
    });
}


/*执行*/
$(function() {

    /*新增角色*/
    win(".add-role",".win-add-role",".btn");
    addRole();

    /*编辑角色名称*/
    win(".edit-role-name",".win-edit-role",".btn");
    editRoleName();

    /*成员管理*/
    win(".edit-members",".win-members",".btn");
    addAndDelMember();

    /*权限设置*/
    win(".edit-power",".win-edit-power",".btn");

    /*删除角色*/
    win(".delete-role",".win-delete",".btn");
});